[Chapter 5] 5.8 chgrp: Changing a File's Group
Author: Simson Garfinkel & Gene Spafford
Date: 1999-02-04T00:02:21Z

#

| Chapter 5 The UNIX Filesystem |

## 5.8 chgrp: Changing a File's Group

The `chgrp` command lets you change the group of a file. The behavior here mirrors that of `chown`. Under most modern versions of UNIX, you can change the group of a file if you are either one of the following users:

- You are the file's owner and you are in the group to which you are trying to change the file.

- You are the superuser.

On older AT&T versions of UNIX, you may set any file you own to any group that you want. That is, you can "give away" files to other groups, the same as you can give away files to other users. Beware.

The `chgrp` command has the form:

>     chgrp [ -fRh ] group filelist

The `-f` and `-R` options are interpreted the same as they are for the `chmod` and `chown` commands. The `-h` option is a bit different from that of `chmod`. Under `chgrp`, the option specifies that the group of the link itself is changed and not what the link points to.

Other entries have the following meanings:

group

  The group to which you are changing the file(s). The group may be specified by name or with its decimal GID.

filelist

  The list of files whose group you are changing.

For example, to change the group of the file paper.tex to chem, you would type:

>     % chgrp chem paper.tex
>     % ls -l paper.tex
>     -rw-r--r-- 1 kevin      chem      59321 Jul 12 13:54 paper.tex
>     %

5.7 chown: Changing a File's Owner |  | 5.9 Oddities and Dubious Ideas